package com.shop.admin.controller;

import com.shop.admin.aop.Log;
import com.shop.admin.service.ISystemConfigService;
import com.shop.admin.validate.SystemConfigUpdateValidate;
import com.shop.admin.vo.SystemConfigDetailVo;
import com.shop.common.core.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("${app.api-prefix}/config")
@Api(tags = "系统全局配置管理")
public class SystemConfigController {

    @Resource
    ISystemConfigService iSystemConfigService;


    @GetMapping("/detail")
    @ApiOperation(value="系统全局配置详情")
    public AjaxResult<SystemConfigDetailVo> detail(@RequestParam("type") String type, @RequestParam("name") String name) {
        SystemConfigDetailVo detail = iSystemConfigService.detail(type, name);
        return AjaxResult.success(detail);
    }

    @Log(title = "系统全局配置编辑")
    @PostMapping("/edit")
    @ApiOperation(value="系统全局配置编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody SystemConfigUpdateValidate updateValidate) {
        iSystemConfigService.edit(updateValidate);
        return AjaxResult.success();
    }
}
